package electricity.enumeration;

public enum DeviceStatusEnum {
    ONLINE(1, "在线"),
    OFFLINE(0, "离线");

    private final Integer code;
    private final String text;

    DeviceStatusEnum(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public static DeviceStatusEnum of(Integer code) {
        if (code == null) return OFFLINE;
        for (DeviceStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return OFFLINE;
    }

    private Object getCode() {
        return code;
    }

    public String getText() {
        return text;
    }
}
